package com.neusoft.my12306.controller;


import com.neusoft.my12306.common.res.CommonResult;
import com.neusoft.my12306.entity.Passenger;
import com.neusoft.my12306.entity.User;
import com.neusoft.my12306.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 葛彬
 * @since 2023-07-15
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    IUserService userService;

    @PutMapping("/sendPhoneMessage")
    public CommonResult<String> sendPhoneMessage(@RequestBody User user) {
        return userService.sendPhoneMessage(user);
    }

    @PutMapping("/register")
    public CommonResult register(@RequestBody User user) {
        return userService.register(user);
    }

    @PostMapping("/login")
    public CommonResult login(@RequestBody User user) {
        return userService.login(user);
    }

    @PostMapping("/query")
    public CommonResult queryPassenger(@RequestParam("passids") List<Integer> passids) {
        return userService.queryPassenger(passids);
    }

    @PostMapping("/pay")
    public CommonResult pay(@RequestParam String name,@RequestParam Double money) {
        return userService.pay(name,money);
    }

    @PostMapping("/myinfo")
    public CommonResult queryMyInfo(@RequestBody User user) {
        return userService.queryMyInfo(user);
    }

}
